import globalConst from "../../common/globalConst";
var global = globalConst.GlobalConst;
import { GlobalVar } from "../../common/globalvar";

var Strokeutil = {}

Strokeutil.active = function (lineDef, graph, map,mapInfo) {
    if (lineDef.linemode == 0){
        return ;
    }
    let scaling = 1;
    if (mapInfo){
        scaling = mapInfo.getLenthDisScale();
    }
    var grd = lineDef.color.toHexString();
    if (graph.getHighLight()){
        grd = GlobalVar.highlightColor.toHexString();
    }
    map.strokeStyle = grd;
    map.lineWidth = 1;
    if (mapInfo && mapInfo.getLineWidthShow()){
        map.lineWidth = lineDef.lineWidth*scaling;
    }
    if (lineDef.linemode == 2){
        map.setLineDash([5,5]);
    }

    if (mapInfo && graph && graph.getSelect() == 1 && mapInfo.editMode == "autocad"){
        map.setLineDash([5,5]);
    }

    map.stroke();
}

export { Strokeutil }
